using ASP;
using HoWave.Common;
using HoWave.Data.Bll;
using HoWave.Data.Model;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class _ShopCartOrderSumbit : Shop, IRequiresSessionState
{
	protected int m_SalerID;
	private string _strProductID = string.Empty;
	private string _strproductNum = string.Empty;
	private string _strproductPrice = string.Empty;
	private string _shopcartID = string.Empty;
	private string _shopID = string.Empty;
	private string _deliverType = string.Empty;
	private string _deliverCharge = string.Empty;
	private string _address = string.Empty;
	private Shop_Product _shop_product = null;
	private Shop_Order _shop_order = null;
	private Shop_Shop _shop_shop = null;
	private UserBll _shopUser = null;
	private Shop_Address _buyeraddress = null;
	private Shop_PayType _shop_payType = null;
	private Shop_DeliverType _db_deliver = null;
	private CreateOrder _CreateOrder = null;
	protected UserControls_cmpy_Top Top1;
	protected ScriptManager ScriptManager1;
	protected Repeater Repeater1;
	protected Button btn_back;
	protected Button btn_next;
	protected HtmlGenericControl shopcartTop;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	protected string strProductID
	{
		get
		{
			this._strProductID = Fetch.Get("productID");
			this._strProductID = this._strProductID.Substring(0, this._strProductID.Length - 1);
			return this._strProductID;
		}
	}
	protected string strProductNum
	{
		get
		{
			this._strproductNum = Fetch.Get("productNum");
			this._strproductNum = this._strproductNum.Substring(0, this._strproductNum.Length - 1);
			return this._strproductNum;
		}
	}
	protected string strProductPrice
	{
		get
		{
			this._strproductPrice = Fetch.Get("productPrice");
			this._strproductPrice = this._strproductPrice.Substring(0, this._strproductPrice.Length - 1);
			return this._strproductPrice;
		}
	}
	protected string shopcartID
	{
		get
		{
			this._shopcartID = Fetch.Get("shopcartID");
			return this._shopcartID;
		}
	}
	protected string shopID
	{
		get
		{
			this._shopID = Fetch.Get("shopID");
			return this._shopID;
		}
	}
	protected string deliverType
	{
		get
		{
			this._deliverType = Fetch.Get("deliverType");
			return this._deliverType;
		}
	}
	protected string deliverCharge
	{
		get
		{
			if (this.Session["DeliverCharge"] != null)
			{
				this._deliverCharge = this.Session["DeliverCharge"].ToString();
			}
			return this._deliverCharge;
		}
	}
	protected string address
	{
		get
		{
			this._address = Fetch.Get("address");
			return this._address;
		}
	}
	protected Shop_Product shop_product
	{
		get
		{
			Shop_Product shop_product;
			if (this._shop_product == null)
			{
				this._shop_product = new Shop_Product(this.conn);
				shop_product = this._shop_product;
			}
			else
			{
				shop_product = this._shop_product;
			}
			return shop_product;
		}
	}
	protected Shop_Order shop_order
	{
		get
		{
			Shop_Order shop_order;
			if (this._shop_order == null)
			{
				this._shop_order = new Shop_Order(this.conn);
				shop_order = this._shop_order;
			}
			else
			{
				shop_order = this._shop_order;
			}
			return shop_order;
		}
	}
	protected Shop_Shop shop_shop
	{
		get
		{
			Shop_Shop shop_shop;
			if (this._shop_shop == null)
			{
				this._shop_shop = new Shop_Shop(this.conn);
				shop_shop = this._shop_shop;
			}
			else
			{
				shop_shop = this._shop_shop;
			}
			return shop_shop;
		}
	}
	protected UserBll shopUser
	{
		get
		{
			UserBll shopUser;
			if (this._shopUser == null)
			{
				this._shopUser = new UserBll(this.conn);
				shopUser = this._shopUser;
			}
			else
			{
				shopUser = this._shopUser;
			}
			return shopUser;
		}
	}
	protected Shop_Address buyeraddress
	{
		get
		{
			Shop_Address buyeraddress;
			if (this._buyeraddress == null)
			{
				this._buyeraddress = new Shop_Address(this.conn);
				buyeraddress = this._buyeraddress;
			}
			else
			{
				buyeraddress = this._buyeraddress;
			}
			return buyeraddress;
		}
	}
	protected Shop_PayType shop_paytype
	{
		get
		{
			Shop_PayType shop_payType;
			if (this._shop_payType == null)
			{
				this._shop_payType = new Shop_PayType(this.conn);
				shop_payType = this._shop_payType;
			}
			else
			{
				shop_payType = this._shop_payType;
			}
			return shop_payType;
		}
	}
	protected Shop_DeliverType db_deliver
	{
		get
		{
			if (this._db_deliver == null)
			{
				this._db_deliver = new Shop_DeliverType(this.conn);
			}
			return this._db_deliver;
		}
	}
	protected CreateOrder CreateOrder
	{
		get
		{
			CreateOrder createOrder;
			if (this._CreateOrder == null)
			{
				this._CreateOrder = new CreateOrder(this.conn);
				createOrder = this._CreateOrder;
			}
			else
			{
				createOrder = this._CreateOrder;
			}
			return createOrder;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_PreInit(object sender, EventArgs e)
	{
		if (!base.user.CheckUserLogin())
		{
			this.WriteErrMsg("", Language.GetMemberMsg("Common/NotLogin", new string[0]), "Passport/Login.aspx?ComeUrl=" + this.InstallDir + "SaleProduct.aspx");
		}
		try
		{
		}
		catch (Exception ex)
		{
			base.WriteTemErrMsg(ex.Message.ToString());
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.loadinfo();
		}
	}
	private void loadinfo()
	{
		this.Repeater1.DataSource = this.setOrderDs();
		this.Repeater1.DataBind();
		for (int i = 0; i < this.Repeater1.Items.Count; i++)
		{
			HiddenField hiddenField = (HiddenField)this.Repeater1.Items[i].FindControl("hfSalerID");
			Label label = (Label)this.Repeater1.Items[i].FindControl("Label2");
			Panel panel = (Panel)this.Repeater1.Items[i].FindControl("Product_Need_Coupon");
			DropDownList dropDownList = (DropDownList)this.Repeater1.Items[i].FindControl("ddlCouponItem");
			HiddenField hiddenField2 = (HiddenField)this.Repeater1.Items[i].FindControl("hfMoneyTotal");
			UserControl userControl = (UserControl)this.Repeater1.Items[i].FindControl("shopOrder1");
			Label label2 = (Label)userControl.FindControl("Label4");
			if (hiddenField != null)
			{
				int num = Convert.ToInt32(hiddenField.Value);
				if (num > 0)
				{
					panel.Style["display"] = "none";
					decimal d = 0m;
					if (!string.IsNullOrEmpty(hiddenField2.Value))
					{
						d = Convert.ToDecimal(hiddenField2.Value);
					}
					if (base.OwnerPromotionPower(num))
					{
						dropDownList.Items.Clear();
						DataTable dataTable = base.UserUseCouponMethod(base.user.UserName, 0, "use", "myself", base.user.GroupID.ToString());
						if (dataTable != null)
						{
							for (int j = 0; j < dataTable.Rows.Count; j++)
							{
								decimal d2 = Convert.ToDecimal(dataTable.Rows[j]["NeedsMoney"].ToString());
								if (d >= d2)
								{
									panel.Style["display"] = "block";
									ListItem listItem = new ListItem();
									listItem.Text = dataTable.Rows[j]["CouponNum"].ToString() + " -- " + dataTable.Rows[j]["CouponParvalue"].ToString();
									listItem.Value = dataTable.Rows[j]["CouponItemID"].ToString();
									dropDownList.Items.Add(listItem);
								}
							}
							ListItem item = new ListItem("请选择", "");
							dropDownList.Items.Insert(0, item);
						}
					}
				}
			}
		}
	}
	private DataSet setOrderDs()
	{
		DataTable dataTable = new DataTable();
		DataColumn column = new DataColumn("orderProductIDS", typeof(string));
		dataTable.Columns.Add(column);
		DataColumn column2 = new DataColumn("shopID", typeof(string));
		dataTable.Columns.Add(column2);
		DataColumn column3 = new DataColumn("productNum", typeof(string));
		dataTable.Columns.Add(column3);
		DataColumn column4 = new DataColumn("DeliverPrice", typeof(decimal));
		dataTable.Columns.Add(column4);
		DataColumn column5 = new DataColumn("UserID", typeof(int));
		dataTable.Columns.Add(column5);
		DataColumn column6 = new DataColumn("BuyerName", typeof(string));
		dataTable.Columns.Add(column6);
		DataColumn column7 = new DataColumn("SalerID", typeof(int));
		dataTable.Columns.Add(column7);
		DataColumn column8 = new DataColumn("SalerName", typeof(string));
		dataTable.Columns.Add(column8);
		DataColumn column9 = new DataColumn("MoneyTotal", typeof(decimal));
		dataTable.Columns.Add(column9);
		DataColumn column10 = new DataColumn("MoneyGoods", typeof(decimal));
		dataTable.Columns.Add(column10);
		DataColumn column11 = new DataColumn("MoneyReceipt", typeof(decimal));
		dataTable.Columns.Add(column11);
		DataColumn column12 = new DataColumn("Remark", typeof(string));
		dataTable.Columns.Add(column12);
		DataColumn column13 = new DataColumn("InputTime", typeof(DateTime));
		dataTable.Columns.Add(column13);
		DataColumn column14 = new DataColumn("UpdateTime", typeof(DateTime));
		dataTable.Columns.Add(column14);
		DataColumn column15 = new DataColumn("Province", typeof(string));
		dataTable.Columns.Add(column15);
		DataColumn column16 = new DataColumn("City", typeof(string));
		dataTable.Columns.Add(column16);
		DataColumn column17 = new DataColumn("Area", typeof(string));
		dataTable.Columns.Add(column17);
		DataColumn column18 = new DataColumn("AddressStr", typeof(string));
		dataTable.Columns.Add(column18);
		DataColumn column19 = new DataColumn("Address", typeof(string));
		dataTable.Columns.Add(column19);
		DataColumn column20 = new DataColumn("ZipCode", typeof(string));
		dataTable.Columns.Add(column20);
		DataColumn column21 = new DataColumn("ContacterName", typeof(string));
		dataTable.Columns.Add(column21);
		DataColumn column22 = new DataColumn("Mobile", typeof(string));
		dataTable.Columns.Add(column22);
		DataColumn column23 = new DataColumn("Phone", typeof(string));
		dataTable.Columns.Add(column23);
		DataColumn column24 = new DataColumn("Email", typeof(string));
		dataTable.Columns.Add(column24);
		DataColumn column25 = new DataColumn("Status", typeof(int));
		dataTable.Columns.Add(column25);
		DataColumn column26 = new DataColumn("DeliverStatus", typeof(int));
		dataTable.Columns.Add(column26);
		DataColumn column27 = new DataColumn("PayStatus", typeof(int));
		dataTable.Columns.Add(column27);
		DataColumn column28 = new DataColumn("InvoiceContent", typeof(string));
		dataTable.Columns.Add(column28);
		DataColumn column29 = new DataColumn("Invoiced", typeof(int));
		dataTable.Columns.Add(column29);
		DataColumn column30 = new DataColumn("NeedInvoice", typeof(string));
		dataTable.Columns.Add(column30);
		DataColumn column31 = new DataColumn("Invoice_TotalPrice", typeof(decimal));
		dataTable.Columns.Add(column31);
		DataColumn column32 = new DataColumn("DeliverTypeName", typeof(string));
		dataTable.Columns.Add(column32);
		DataColumn column33 = new DataColumn("Deliver_TotalPrice", typeof(decimal));
		dataTable.Columns.Add(column33);
		DataColumn column34 = new DataColumn("Cycle", typeof(int));
		dataTable.Columns.Add(column34);
		DataColumn column35 = new DataColumn("AuctionEndPrice", typeof(decimal));
		dataTable.Columns.Add(column35);
		DataColumn column36 = new DataColumn("TeamBuyLeavel", typeof(decimal));
		dataTable.Columns.Add(column36);
		DataColumn column37 = new DataColumn("increment", typeof(decimal));
		dataTable.Columns.Add(column37);
		DataColumn column38 = new DataColumn("shopName", typeof(string));
		dataTable.Columns.Add(column38);
		DataColumn column39 = new DataColumn("deliverType", typeof(int));
		dataTable.Columns.Add(column39);
		DataColumn column40 = new DataColumn("deliverCharge", typeof(string));
		dataTable.Columns.Add(column40);
		DataColumn column41 = new DataColumn("TradeType", typeof(int));
		dataTable.Columns.Add(column41);
		DataColumn column42 = new DataColumn("productPrice", typeof(string));
		dataTable.Columns.Add(column42);
		string[] array = this.strProductID.Split(new char[]
		{
			'|'
		});
		string[] array2 = this.strProductNum.Split(new char[]
		{
			'|'
		});
		string[] array3 = this.strProductPrice.Split(new char[]
		{
			'|'
		});
		string[] array4 = this.deliverType.Split(new char[]
		{
			','
		});
		string[] array5 = this.deliverCharge.Split(new char[]
		{
			'|'
		});
		string[] array6 = this.shopID.Split(new char[]
		{
			','
		});
		string[] array7 = this.address.Split(new char[]
		{
			','
		});
		for (int i = 0; i < array4.Length; i++)
		{
			string text = "";
			DataRow dataRow = dataTable.NewRow();
			dataRow["deliverType"] = int.Parse(array4[i]);
			dataRow["orderProductIDS"] = array[i];
			DataTable productadnshopByProductIDS = this.shop_product.getProductadnshopByProductIDS(array[i]);
			if (!string.IsNullOrEmpty(array5[i]))
			{
				text = array5[i];
			}
			dataRow["deliverCharge"] = text;
			dataRow["shopID"] = array6[i];
			dataRow["productNum"] = array2[i];
			dataRow["productPrice"] = array3[i];
			if (productadnshopByProductIDS != null && !string.IsNullOrEmpty(productadnshopByProductIDS.ToString()) && productadnshopByProductIDS.Rows.Count > 0)
			{
				dataRow["TradeType"] = productadnshopByProductIDS.Rows[i]["ProductType"].ToString();
			}
			else
			{
				dataRow["TradeType"] = 1;
			}
			DataTable shopByShopID = this.shop_shop.GetShopByShopID(int.Parse(array6[i]));
			try
			{
				dataRow["shopName"] = shopByShopID.Rows[0]["shopName"].ToString();
				dataRow["SalerID"] = shopByShopID.Rows[0]["ShopOwnerID"].ToString();
				dataRow["SalerName"] = shopByShopID.Rows[0]["ShopOwnerName"].ToString();
			}
			catch
			{
				dataRow["shopName"] = string.Empty;
				dataRow["SalerID"] = 0;
				dataRow["SalerName"] = string.Empty;
			}
			dataRow["UserID"] = base.user.UserID;
			dataRow["BuyerName"] = base.user.UserName;
			DataTable addressByID = this.buyeraddress.GetAddressByID(int.Parse(array7[i]));
			try
			{
				string text2 = addressByID.Rows[0]["Province"].ToString();
				string text3 = addressByID.Rows[0]["City"].ToString();
				string text4 = "";
				if (addressByID.Columns.Contains("CMArea"))
				{
					if (addressByID.Rows[0]["CMArea"] != DBNull.Value)
					{
						text4 = addressByID.Rows[0]["CMArea"].ToString();
					}
				}
				dataRow["Province"] = text2;
				dataRow["City"] = text3;
				dataRow["Area"] = text4;
				string text5 = addressByID.Rows[0]["Address"].ToString();
				dataRow["AddressStr"] = text2 + text3 + text4 + text5;
				dataRow["address"] = text5;
				dataRow["ZipCode"] = addressByID.Rows[0]["ZipCode"].ToString();
				dataRow["ContacterName"] = addressByID.Rows[0]["UserName"].ToString();
				string text6 = addressByID.Rows[0]["MobilePhone"].ToString();
				string value = addressByID.Rows[0]["ConectPhone"].ToString();
				dataRow["Mobile"] = text6;
				dataRow["Phone"] = value;
				if (text6 != "" || text6 != null)
				{
					dataRow["Phone"] = text6;
				}
				dataRow["Email"] = addressByID.Rows[0]["Email"].ToString();
			}
			catch
			{
				dataRow["Province"] = string.Empty;
				dataRow["City"] = string.Empty;
				dataRow["Area"] = string.Empty;
				dataRow["AddressStr"] = string.Empty;
				dataRow["address"] = string.Empty;
				dataRow["ZipCode"] = string.Empty;
				dataRow["ContacterName"] = base.user.UserInforRes["TrueName"].ToString();
				dataRow["Mobile"] = string.Empty;
				dataRow["Phone"] = string.Empty;
				dataRow["Email"] = string.Empty;
			}
			dataRow["Status"] = 0;
			dataRow["DeliverStatus"] = 0;
			dataRow["PayStatus"] = 0;
			dataRow["Invoiced"] = 0;
			dataRow["NeedInvoice"] = 0;
			dataRow["InvoiceContent"] = "";
			dataRow["Invoice_TotalPrice"] = 0;
			dataRow["TeamBuyLeavel"] = 0;
			dataRow["AuctionEndPrice"] = 0;
			dataRow["Cycle"] = 0;
			dataRow["MoneyReceipt"] = 0;
			dataRow["Remark"] = "";
			dataRow["InputTime"] = DateTime.Now;
			dataRow["UpdateTime"] = DateTime.Now;
			string[] array8 = array2[i].Split(new char[]
			{
				','
			});
			int[] array9 = new int[array8.Length];
			string[] array10 = array3[i].Split(new char[]
			{
				','
			});
			decimal[] array11 = new decimal[array10.Length];
			for (int j = 0; j < array8.Length; j++)
			{
				try
				{
					array9[j] = int.Parse(array8[j]);
				}
				catch
				{
				}
			}
			for (int j = 0; j < array10.Length; j++)
			{
				try
				{
					array11[j] = Convert.ToDecimal(array10[j]);
				}
				catch
				{
				}
			}
			decimal num = 0m;
			try
			{
				if (!string.IsNullOrEmpty(text))
				{
					decimal num2 = 0m;
					decimal num3 = 0m;
					string[] contentArray = text.ToString().Split(new char[]
					{
						'$'
					});
					string deliverChargeContentDetailByName = Shop_DeliverType.GetDeliverChargeContentDetailByName("deliverName", contentArray);
					string deliverChargeContentDetailByName2 = Shop_DeliverType.GetDeliverChargeContentDetailByName("defaultPrice", contentArray);
					if (!string.IsNullOrEmpty(deliverChargeContentDetailByName2))
					{
						num2 = deliverChargeContentDetailByName2.ToDecimal2();
					}
					string deliverChargeContentDetailByName3 = Shop_DeliverType.GetDeliverChargeContentDetailByName("deincrementPrice", contentArray);
					if (!string.IsNullOrEmpty(deliverChargeContentDetailByName3))
					{
						num3 = deliverChargeContentDetailByName3.ToDecimal2();
					}
					dataRow["DeliverTypeName"] = deliverChargeContentDetailByName;
					dataRow["DeliverPrice"] = num2;
					dataRow["increment"] = num3;
					num = this.CreateOrder.GetDeliverPrice(array9, num2, num3);
				}
				else
				{
					dataRow["DeliverTypeName"] = "";
					dataRow["DeliverPrice"] = 0;
					dataRow["increment"] = 0;
				}
			}
			catch
			{
			}
			dataRow["Deliver_TotalPrice"] = num;
			string[] array12 = array[i].Split(new char[]
			{
				','
			});
			int[] array13 = new int[array12.Length];
			for (int j = 0; j < array12.Length; j++)
			{
				array13[j] = int.Parse(array12[j]);
			}
			decimal productTotalPrice = this.CreateOrder.GetProductTotalPrice(array13, array9, array11);
			dataRow["MoneyGoods"] = productTotalPrice;
			dataRow["MoneyTotal"] = productTotalPrice + num;
			dataTable.Rows.Add(dataRow);
		}
		return new DataSet
		{
			Tables = 
			{
				dataTable
			}
		};
	}
	protected void btn_next_Click(object sender, EventArgs e)
	{
		string text = "";
		DataTable dataTable = new DataTable();
		DataColumn column = new DataColumn("userID", typeof(int));
		dataTable.Columns.Add(column);
		DataColumn column2 = new DataColumn("BuyerName", typeof(string));
		dataTable.Columns.Add(column2);
		DataColumn column3 = new DataColumn("shopID", typeof(int));
		dataTable.Columns.Add(column3);
		DataColumn column4 = new DataColumn("SalerID", typeof(int));
		dataTable.Columns.Add(column4);
		DataColumn column5 = new DataColumn("SalerName", typeof(string));
		dataTable.Columns.Add(column5);
		DataColumn column6 = new DataColumn("MoneyTotal", typeof(decimal));
		dataTable.Columns.Add(column6);
		DataColumn column7 = new DataColumn("MoneyGoods", typeof(decimal));
		dataTable.Columns.Add(column7);
		DataColumn column8 = new DataColumn("Province", typeof(string));
		dataTable.Columns.Add(column8);
		DataColumn column9 = new DataColumn("City", typeof(string));
		dataTable.Columns.Add(column9);
		DataColumn column10 = new DataColumn("Area", typeof(string));
		dataTable.Columns.Add(column10);
		DataColumn column11 = new DataColumn("Address", typeof(string));
		dataTable.Columns.Add(column11);
		DataColumn column12 = new DataColumn("ZipCode", typeof(string));
		dataTable.Columns.Add(column12);
		DataColumn column13 = new DataColumn("ContacterName", typeof(string));
		dataTable.Columns.Add(column13);
		DataColumn column14 = new DataColumn("Mobile", typeof(string));
		dataTable.Columns.Add(column14);
		DataColumn column15 = new DataColumn("Phone", typeof(string));
		dataTable.Columns.Add(column15);
		DataColumn column16 = new DataColumn("Email", typeof(string));
		dataTable.Columns.Add(column16);
		DataColumn column17 = new DataColumn("InvoiceContent", typeof(string));
		dataTable.Columns.Add(column17);
		DataColumn column18 = new DataColumn("Invoice_TotalPrice", typeof(decimal));
		dataTable.Columns.Add(column18);
		DataColumn column19 = new DataColumn("DeliverTypeID", typeof(string));
		dataTable.Columns.Add(column19);
		DataColumn column20 = new DataColumn("Deliver_TotalPrice", typeof(decimal));
		dataTable.Columns.Add(column20);
		DataColumn column21 = new DataColumn("DeliverPrice", typeof(decimal));
		dataTable.Columns.Add(column21);
		DataColumn column22 = new DataColumn("Increment", typeof(decimal));
		dataTable.Columns.Add(column22);
		DataColumn column23 = new DataColumn("deliverCharge", typeof(string));
		dataTable.Columns.Add(column23);
		DataColumn column24 = new DataColumn("orderProductIDS", typeof(string));
		dataTable.Columns.Add(column24);
		DataColumn column25 = new DataColumn("productNum", typeof(string));
		dataTable.Columns.Add(column25);
		DataColumn column26 = new DataColumn("InvoicedHas", typeof(string));
		dataTable.Columns.Add(column26);
		DataColumn column27 = new DataColumn("NeedInvoice", typeof(string));
		dataTable.Columns.Add(column27);
		DataColumn column28 = new DataColumn("NeedInvoiceProduct", typeof(string));
		dataTable.Columns.Add(column28);
		DataColumn column29 = new DataColumn("DeliverTypeName", typeof(string));
		dataTable.Columns.Add(column29);
		DataColumn column30 = new DataColumn("TradeType", typeof(int));
		dataTable.Columns.Add(column30);
		DataColumn column31 = new DataColumn("StandPrice", typeof(string));
		dataTable.Columns.Add(column31);
		DataColumn column32 = new DataColumn("CouponItemID", typeof(string));
		dataTable.Columns.Add(column32);
		DataColumn column33 = new DataColumn("Remark", typeof(string));
		dataTable.Columns.Add(column33);
		DataTable dataTable2 = this.setOrderDs().Tables[0];
		int count = this.Repeater1.Items.Count;
		string text2 = "";
		for (int i = 0; i < count; i++)
		{
			text = "";
			string str = "";
			DataView defaultView = dataTable2.DefaultView;
			Panel panel = (Panel)this.Repeater1.Items[i].FindControl("Product_Need_Coupon");
			DropDownList dropDownList = (DropDownList)this.Repeater1.Items[i].FindControl("ddlCouponItem");
			int num = 0;
			if (panel.Style["display"] == "block")
			{
				for (int j = 0; j < dropDownList.Items.Count; j++)
				{
					string text3 = "";
					if (dropDownList.Items[j].Selected)
					{
						if (dropDownList.Items[j].Value != "")
						{
							if (text2 == "")
							{
								num = Convert.ToInt32(dropDownList.Items[j].Value);
								text3 = text3 + num + ",";
							}
							else
							{
								if (text2.Contains(","))
								{
									string[] array = text2.Split(new string[]
									{
										","
									}, StringSplitOptions.RemoveEmptyEntries);
									for (int k = 0; k < array.Length; k++)
									{
										if (dropDownList.Items[j].Value != array[k])
										{
											num = Convert.ToInt32(dropDownList.Items[j].Value);
											text3 = text3 + num + ",";
										}
									}
								}
								else
								{
									if (dropDownList.Items[j].Value != text2)
									{
										num = Convert.ToInt32(dropDownList.Items[j].Value);
										text3 = text3 + num + ",";
									}
								}
							}
							if (text3 != "")
							{
								text2 += text3;
							}
							break;
						}
					}
				}
			}
			DataRow dataRow = dataTable.NewRow();
			dataRow["CouponItemID"] = num;
			UserControl userControl = (UserControl)this.Repeater1.Items[i].FindControl("shopOrder1");
			TextBox textBox = (TextBox)userControl.FindControl("TextBox1");
			HiddenField hiddenField = (HiddenField)userControl.FindControl("hd_deliverType");
			Label label = (Label)userControl.FindControl("Label4");
			decimal couponValue = BLLInstance.BllCouponItem.GetCouponValue(num);
			label.Text = (Convert.ToDecimal(label.Text) - couponValue).ToString();
			Label label2 = (Label)userControl.FindControl("Label3");
			HiddenField hiddenField2 = (HiddenField)userControl.FindControl("hd_InvoiceTotalPrice");
			HiddenField hiddenField3 = (HiddenField)userControl.FindControl("hd_NeedInvoiceOrder");
			HiddenField hiddenField4 = (HiddenField)userControl.FindControl("hd_NeedInvoice");
			TextBox textBox2 = (TextBox)userControl.FindControl("Remark");
			string value = "";
			if (textBox2 != null)
			{
				value = textBox2.Text;
			}
			dataRow["Remark"] = value;
			string value2 = "0";
			string value3 = "0";
			GridView gridView = (GridView)userControl.FindControl("GridView1");
			for (int l = 0; l < gridView.Rows.Count; l++)
			{
				CheckBox checkBox = (CheckBox)gridView.Rows[l].FindControl("isNeedInvoice");
				CheckBox checkBox2 = (CheckBox)gridView.Rows[l].FindControl("cb_select");
				if (checkBox.Checked)
				{
					value2 = "1";
				}
				if (checkBox2.Checked)
				{
					text += "1,";
					value3 = "1";
				}
				else
				{
					text += "0,";
				}
				str = str + (decimal.Parse(gridView.Rows[l].Cells[4].Text) / int.Parse(gridView.Rows[l].Cells[3].Text)).ToString() + ",";
			}
			defaultView.RowFilter = "deliverType=" + int.Parse(hiddenField.Value);
			HiddenField hiddenField5 = (HiddenField)this.Repeater1.Items[i].FindControl("hfSalerID");
			if (hiddenField5 != null)
			{
				DataView expr_A4E = defaultView;
				expr_A4E.RowFilter = expr_A4E.RowFilter + " and SalerID=" + hiddenField5.Value;
			}
			dataRow["userID"] = int.Parse(defaultView[0]["userID"].ToString());
			dataRow["BuyerName"] = defaultView[0]["BuyerName"].ToString();
			dataRow["shopID"] = int.Parse(defaultView[0]["shopID"].ToString());
			dataRow["SalerID"] = int.Parse(defaultView[0]["SalerID"].ToString());
			dataRow["SalerName"] = defaultView[0]["SalerName"].ToString();
			dataRow["MoneyTotal"] = decimal.Parse(label.Text);
			dataRow["MoneyGoods"] = decimal.Parse(label2.Text);
			dataRow["Province"] = defaultView[0]["Province"].ToString();
			dataRow["City"] = defaultView[0]["City"].ToString();
			dataRow["Area"] = defaultView[0]["Area"].ToString();
			dataRow["Address"] = defaultView[0]["Address"].ToString();
			dataRow["ZipCode"] = defaultView[0]["ZipCode"].ToString();
			dataRow["ContacterName"] = defaultView[0]["ContacterName"].ToString();
			dataRow["Mobile"] = defaultView[0]["Mobile"].ToString();
			dataRow["Phone"] = defaultView[0]["Phone"].ToString();
			dataRow["Email"] = defaultView[0]["Email"].ToString();
			dataRow["InvoiceContent"] = textBox.Text;
			dataRow["TradeType"] = defaultView[0]["TradeType"].ToString();
			try
			{
				dataRow["DeliverPrice"] = 0;
				if (!string.IsNullOrEmpty(defaultView[0]["DeliverPrice"].ToString()))
				{
					dataRow["DeliverPrice"] = decimal.Parse(defaultView[0]["DeliverPrice"].ToString());
				}
			}
			catch
			{
				dataRow["DeliverPrice"] = 0;
			}
			try
			{
				dataRow["Increment"] = 0;
				if (!string.IsNullOrEmpty(defaultView[0]["Increment"].ToString()))
				{
					dataRow["Increment"] = decimal.Parse(defaultView[0]["Increment"].ToString());
				}
			}
			catch
			{
				dataRow["Increment"] = 0;
			}
			try
			{
				dataRow["deliverCharge"] = "";
				if (!string.IsNullOrEmpty(defaultView[0]["deliverCharge"].ToString()))
				{
					dataRow["deliverCharge"] = defaultView[0]["deliverCharge"].ToString();
				}
				dataRow["Deliver_TotalPrice"] = "0";
				if (!string.IsNullOrEmpty(defaultView[0]["Deliver_TotalPrice"].ToString()))
				{
					dataRow["Deliver_TotalPrice"] = defaultView[0]["Deliver_TotalPrice"].ToString();
				}
			}
			catch
			{
			}
			try
			{
				dataRow["Invoice_TotalPrice"] = 0;
				if (!string.IsNullOrEmpty(hiddenField2.Value))
				{
					dataRow["Invoice_TotalPrice"] = decimal.Parse(hiddenField2.Value);
				}
			}
			catch
			{
				dataRow["Invoice_TotalPrice"] = 0;
			}
			dataRow["orderProductIDS"] = defaultView[0]["orderProductIDS"].ToString();
			dataRow["productNum"] = defaultView[0]["productNum"].ToString();
			dataRow["DeliverTypeName"] = defaultView[0]["DeliverTypeName"].ToString();
			if (!string.IsNullOrEmpty(text))
			{
				text = text.Substring(0, text.Length - 1);
			}
			dataRow["InvoicedHas"] = value2;
			dataRow["NeedInvoice"] = value3;
			dataRow["NeedInvoiceProduct"] = text;
			dataRow["StandPrice"] = defaultView[0]["productPrice"].ToString();
			dataRow["DeliverTypeID"] = defaultView[0]["deliverType"].ToString();
			dataTable.Rows.Add(dataRow);
		}
		if (this.CreateOrder.creatOrders(dataTable))
		{
			foreach (DataRow dataRow2 in dataTable.Rows)
			{
				int dianpuID = int.Parse(dataRow2["shopID"].ToString());
				base.ClientRelation(dianpuID, "buyorder");
				int couponID = int.Parse(dataRow2["CouponItemID"].ToString());
				this.UseCouponItem(couponID);
			}
			this.delInfo();
			this.WriteSuccessMsg("", "下单成功,请留意会员中心定单管理", "member/Shop_BuyManageOrder.aspx");
		}
		else
		{
			base.Response.Write("<script>alert('下单失败')</script>");
		}
	}
	public DataTable getOrderByOrderId(string orderid)
	{
		DataTable result = null;
		if (!string.IsNullOrEmpty(orderid))
		{
			string sql = "select OrderFormNum,SalerName from HLShop_Order where OrderFormID=" + orderid;
			result = this.conn.GetDataTable(sql);
		}
		return result;
	}
	private void UseCouponItem(int couponID)
	{
		if (couponID > 0)
		{
			HoWave.Data.Model.CouponItem model = BLLInstance.BllCouponItem.GetModel(couponID);
			if (model != null)
			{
				string smtpserver = this.config["MailSmtpServer"].ToString();
				string mailuser = this.config["MailServerUserName"].ToString();
				string mailpassword = this.config["MailServerPassWord"].ToString();
				string mailFrom = this.config["MailServerFrom"].ToString();
				string text = "使用优惠券通知";
				if (!string.IsNullOrEmpty(model.UseOrderID.ToString()))
				{
					DataTable orderByOrderId = this.getOrderByOrderId(model.UseOrderID.ToString());
					if (orderByOrderId.Rows.Count > 0)
					{
						string text2 = orderByOrderId.Rows[0]["OrderFormNum"].ToString();
						string text3 = string.Concat(new string[]
						{
							base.user.UserName,
							"您好：您已经在订单号为",
							text2,
							"，使用了编号为：",
							model.CouponNum,
							"的优惠劵。"
						});
						model.MessageStatus = true;
						string sender = orderByOrderId.Rows[0]["SalerName"].ToString();
						MessageBll messageBll = new MessageBll(this.conn);
						bool flag = messageBll.AddMessage(sender, "Users", text, text3, 0, 0, 1, 0, base.user.UserName, "", 1);
						if (!string.IsNullOrEmpty(base.user.UserEmail))
						{
							string userEmail = base.user.UserEmail;
							model.EmailStatus = true;
							Email email = new Email();
							bool flag2 = email.SendEmail(smtpserver, mailuser, mailpassword, mailFrom, text3, userEmail, text);
						}
						string text4 = base.user.UserInforRes["MobilePhone"].ToString();
						if (!string.IsNullOrEmpty(text4))
						{
							model.MobileStatus = true;
							MobileMessage mobileMessage = new MobileMessage();
							bool flag3 = mobileMessage.Send(text4, text3, base.user.UserName);
						}
						model.CouponItemID = couponID;
						BLLInstance.BllCouponItem.Update(model);
					}
				}
			}
		}
	}
	private void delInfo()
	{
		DataTable dataTable = BLLInstance.BllShoppingCarts.GetList(" CartID in (" + this.shopcartID + ")").Tables[0];
		for (int i = 0; i < dataTable.Rows.Count; i++)
		{
			DataRow dataRow = dataTable.Rows[i];
			int num = dataRow["CartID"].ToInt32(new int[0]);
			if (num > 0)
			{
				BLLInstance.BllShoppingCarts.Delete(num);
			}
		}
	}
	protected void btn_back_Click(object sender, EventArgs e)
	{
		base.Response.Redirect("SetSendAndPayment.aspx?shopcartID=" + this.shopcartID);
	}
}
